home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2007 September / PCWSEP07.iso / Software / Linux / Linux Mint 3.0 Light / LinuxMint-3.0-Light.iso / casper / filesystem.squashfs / var / lib / dpkg / info / libc6.postinst < prev    next >
Encoding:
Text File  |  2007-04-04  |  11.9 KB  |  410 lines

  1. #!/bin/sh
  2. set -e
  3. export LC_ALL=C
  4.  
  5. type=$1
  6. preversion=$2
  7.  
  8. package_name()
  9. {
  10.     echo libc6
  11. }
  12.  
  13. # Borrowed from sysvinit's postinst.
  14. #    Function like update-rc.d but simpler & faster.
  15. #    Usage: updatercd basename start|stop NN runlevel .
  16. #
  17. #    Now we use the real update-rc.d, so now this function should
  18. #    be equivalent to /usr/sbin/update-rc.d.
  19. #
  20. updatercd() {
  21.  
  22.     if [ ! -f /etc/init.d/$1 ]
  23.     then
  24.         return
  25.     fi
  26.  
  27.     if [ -x /usr/sbin/update-rc.d ]
  28.     then
  29.         update-rc.d "$@" > /dev/null
  30.         return $?
  31.     fi
  32.  
  33.     base=$1
  34.     shift
  35.     while [ "$1" != "" ]
  36.     do
  37.         if [ "$1" = stop ]
  38.         then
  39.             tlet=K
  40.         else
  41.             tlet=S
  42.         fi
  43.         lev=$2
  44.         shift 2
  45.         while [ "$1" != "." ]
  46.         do
  47.             cd /etc/rc$1.d
  48.             tmp="`echo $tlet??$base`"
  49.             case "$tmp" in
  50.                 "$tlet??$base")
  51.                     # Not present yet.
  52.                     ln -s ../init.d/$base $tlet$lev$base
  53.                     ;;
  54.                 *)
  55.                     # Already present.
  56.                     ;;
  57.             esac
  58.             shift
  59.         done
  60.         shift
  61.     done
  62. }
  63.  
  64. # element() is a helper function for file-rc:
  65. element() {
  66.     local element list IFS
  67.  
  68.     element="$1"
  69.  
  70.     [ "$2" = "in" ] && shift
  71.     list="$2"
  72.     [ "$list" = "-" ] && return 1
  73.     [ "$list" = "*" ] && return 0
  74.  
  75.     IFS=","
  76.     set -- $list
  77.     case $element in
  78.     "$1"|"$2"|"$3"|"$4"|"$5"|"$6"|"$7"|"$8"|"$9")
  79.         return 0
  80.     esac
  81.     return 1
  82. }
  83.  
  84. # filerc (runlevel, service) returns /etc/init.d/service, if service is
  85. # running in $runlevel:
  86. filerc() {
  87.     local runlevel basename
  88.     runlevel=$1
  89.     basename=$2
  90.     while read LINE
  91.     do
  92.     case $LINE in
  93.         \#*|"") continue
  94.     esac
  95.  
  96.     set -- $LINE
  97.     SORT_NO="$1"; STOP="$2"; START="$3"; CMD="$4"
  98.     [ "$CMD" = "/etc/init.d/$basename" ] || continue
  99.  
  100.     if element "$runlevel" in "$START" || element "S" in "$START"
  101.     then
  102.         echo "/etc/init.d/$basename"
  103.         return 0
  104.     fi
  105.     done < /etc/runlevel.conf
  106.     echo ""
  107. }
  108.  
  109. checkpkgver () {
  110.     local status pkg
  111.     pkg=$1
  112.     status=$(dpkg -s $pkg 2>/dev/null | grep ^Status: | sed -e 's/^Status: \(.*\) \(.*\) \(.*\)/\3/g')
  113.     if [ -n "$status" ] && [ "$status" != "not-installed" ] && [ "$status" != "config-files" ]; then
  114.     echo $(dpkg -s $pkg 2>/dev/null | grep ^Version: | sed -e 's/^Version: *//');
  115.     fi
  116. }
  117.  
  118. # We remove a relic of the past /usr/doc/<package> symlinks.
  119. # This script should keep at least until sarge release.
  120. package=libc6
  121. if [ -L "/usr/doc/$package" ]; then
  122.     rm -f "/usr/doc/$package"
  123. fi
  124. # I'm so lazy that libc6-{dbg,dev,pic,prof} are removed in this file - gotom.
  125. for suffix in -dbg -dev -pic -prof; do
  126.     package_name="$package""$suffix"
  127.     if [ -L "/usr/doc/$package_name" ]; then
  128.     rm -f "/usr/doc/$package_name"
  129.     fi
  130. done
  131.  
  132. if [ "$type" = "configure" ]
  133. then
  134.     # Handle upgrades for libdb.so.3. We do this before calling ldconfig,
  135.     # since it will create a symlink for us. Just move everything over. We
  136.     # use `cat' because I feel it is simpler and safer. Make sure that
  137.     # libdb.so.3 is either a symlink, or non-existent, just in case
  138.     # something weird happened and the new libdb2 is unpacked before we
  139.     # get here.
  140.     if [ -e /lib/libdb.so.3.old ]; then
  141.     if [ -L /lib/libdb.so.3 ] || [ ! -e /lib/libdb.so.3 ]; then
  142.         rm -f /lib/libdb.so.3
  143.         cat /lib/libdb.so.3.old > /lib/libdb.so.3
  144.     fi
  145.     rm -f /lib/libdb.so.3.old
  146.     fi
  147.  
  148.     # Add support for /etc/ld.so.conf.d
  149.     if dpkg --compare-versions "$preversion" lt 2.4-1ubuntu11; then
  150.     if [ -e /etc/ld.so.conf ]; then
  151.         [ -z "$(tail -n 1 /etc/ld.so.conf)" ] || echo >> /etc/ld.so.conf
  152.     else
  153.         touch /etc/ld.so.conf
  154.     fi
  155.     if ! grep -q '^include /etc/ld.so.conf.d/.*\.conf$' /etc/ld.so.conf ; then
  156.         echo 'include /etc/ld.so.conf.d/*.conf' >> /etc/ld.so.conf
  157.     fi
  158.     fi
  159.  
  160.     # Handle upgrades when libc-opt package has been installed.
  161.     # We check the version between the current installed libc and libc-opt.
  162.     # If they're unmatched, we keep /etc/ld.so.nohwcap file until libc-opt
  163.     # package is installed or removed.
  164.     if [ -f /etc/ld.so.nohwcap ]; then
  165.     # We check the availability of ld.so.hwcappkgs.  If it's not existed,
  166.     # it's first time to install ld.so.hwcappkgs aware packages.  We record
  167.     # all current hwcap package status.
  168.     if [ ! -f /etc/ld.so.hwcappkgs ]; then
  169.         case $(dpkg --print-architecture) in
  170.         i386)
  171.             hwcappkgs="libc6 libc6-i686 libc6-xen"
  172.             ;;
  173.         kfreebsd-i386)
  174.             hwcappkgs="libc0.1 libc0.1-i686" 
  175.             ;;
  176.         sparc)
  177.             hwcappkgs="libc6 libc6-sparcv9b libc6-sparcv9v libc6-sparc64b libc6-sparc64v"
  178.             ;;
  179.         esac
  180.         if [ -n "$hwcappkgs" ]; then
  181.         for pkg in $hwcappkgs; do
  182.             ver=$(checkpkgver $pkg)
  183.             if [ -n "$ver" ]; then
  184.             echo "$pkg $ver" >> /etc/ld.so.hwcappkgs
  185.             new_hwcappkgs=yes
  186.             fi
  187.         done
  188.         fi
  189.     fi
  190.  
  191.     # If ld.so.hwcappkgs is existed, it may have one or more opt packages.
  192.     # Update the current package's version, and compare the consistency of
  193.     # those optimized packages.  If inconsistency is found, keep
  194.     # /etc/ld.so.nohwcap.
  195.     if [ -f /etc/ld.so.hwcappkgs ]; then
  196.         curver=2.5-0ubuntu14
  197.         rm -f /etc/ld.so.hwcappkgs.tmp
  198.         while read LINE; do
  199.         case $LINE in
  200.             \#*|"") continue
  201.         esac
  202.         set -- $LINE
  203.         pkg=$1; ver=$2
  204.         if [ "$pkg" = "$package" ]; then
  205.             # libc6
  206.             ver=$curver
  207.             isrecorded=yes
  208.         else
  209.             if [ "$new_hwcappkgs" != yes ]; then
  210.             ver=$(checkpkgver $pkg)
  211.             fi
  212.             if [ -z "$ver" ]; then
  213.             continue
  214.             fi
  215.             dpkg --compare-versions $curver ne $ver && optunmatch=yes
  216.         fi
  217.         echo "$pkg $ver" >> /etc/ld.so.hwcappkgs.tmp
  218.         done < /etc/ld.so.hwcappkgs
  219.         if [ "$isrecorded" != yes ]; then
  220.         echo "$package $curver" >> /etc/ld.so.hwcappkgs.tmp
  221.         fi
  222.         mv /etc/ld.so.hwcappkgs.tmp /etc/ld.so.hwcappkgs
  223.     fi
  224.  
  225.     # nohwcap during upgrade.
  226.     egrep -v '^glibc$|^downgrade-to-old-glibc$' /etc/ld.so.nohwcap > /etc/ld.so.nohwcap.tmp || true
  227.     mv /etc/ld.so.nohwcap.tmp /etc/ld.so.nohwcap
  228.     if [ "$optunmatch" != "yes" ]; then
  229.         test -s /etc/ld.so.nohwcap || rm -f /etc/ld.so.nohwcap
  230.     fi
  231.     fi
  232.  
  233.     if [ ! -z "$preversion" ]; then
  234.     if [ ! -d /var/mail ] && [ ! -L /var/mail ]; then
  235.         ln -sf spool/mail /var/mail
  236.     fi
  237.     if dpkg --compare-versions "$preversion" lt 2.3.5-1; then
  238.         echo -n "Checking for services that may need to be restarted..."
  239.  
  240.         check="nis smail sendmail exim exim4-base ssh netbase"
  241.         check="$check ssh-nonfree postfix-tls wu-ftpd boa cron postfix"
  242.         check="$check wu-ftpd-academ vsftpd slapd openldapd wwwoffle"
  243.         check="$check cupsys lprng lpr lpr-ppd autofs snmpd ssh-krb5"
  244.         check="$check courier-authdaemon mysql-server spamassassin"
  245.         check="$check apache apache-ssl apache-perl apache2-common"
  246.         check="$check proftpd proftpd-ldap proftpd-mysql proftpd-pgsql"
  247.         check="$check dovecot-common cucipop rsync samba saslauthd"
  248.         check="$check webmin dropbear"
  249.         # Only get the ones that are installed, and configured
  250.         check=$(dpkg -s $check 2> /dev/null | egrep '^Package:|^Status:' | awk '{if ($1 ~ /^Package:/) { package=$2 } else if ($0 ~ /^Status: .* installed$/) { print package }}')
  251.         # apache2 ships its init script in apache2-common, but the
  252.         # script is apache2
  253.         check=$(echo $check | sed 's/apache2-common/apache2/g')
  254.         # exim4 ships its init script in exim4-base, but the script
  255.         # is exim4
  256.         check=$(echo $check | sed 's/exim4-base/exim4/g')
  257.         # The name of proftpd-{ldap,mysql,pgsql} init script is
  258.         # same as "proftpd".
  259.         check=$(echo $check | sed 's/proftpd-.*/proftpd/g')
  260.         # dovecot-common ships its init script, but the
  261.         # script name is dovecot for dovecot-{imapd,pop3d}.
  262.         check=$(echo $check | sed 's/dovecot-common/dovecot/g')
  263.         # lpr and lpr-ppd ship its init script, but the 
  264.         # script name is lpd and lpd-ppd.  The inserted space is
  265.         # intentional to not replace lprng.
  266.         check=$(echo $check | sed 's/lpr /lpd /g')
  267.         check=$(echo $check | sed 's/lpr-ppd /lpd-ppd /g')
  268.         # We have to list inetd and atd explicitly, because the packages
  269.         # have different names to their init scripts
  270.         check="$check inetd atd"
  271.         rl=$(runlevel | awk '{print $2}')
  272.         for service in $check; do
  273.         if [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  274.             idl=$(filerc $rl $service)
  275.         else
  276.             idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
  277.         fi
  278.         if [ -n "$idl" ] && [ -x $idl ]; then
  279.             services="$service $services"
  280.         fi
  281.         done
  282.         echo "done."
  283.         if [ -n "$services" ]; then
  284.         echo
  285.         echo "Name Service Switch update in the C Library: post-installation question."
  286.         echo
  287.         echo "Running services and programs that are using NSS need to be restarted,"
  288.         echo "otherwise they might not be able to do lookup or authentication any more"
  289.         echo "(for services such as ssh, this can affect your ability to login)."
  290.         echo "Note: restarting sshd/telnetd should not affect any existing connections."
  291.         echo
  292.         echo "The services detected are: "
  293.         echo "        $services"
  294.         echo
  295.         echo "If other services have begun to fail mysteriously after this upgrade, it is"
  296.         echo "probably necessary to restart them too.  We recommend that you reboot your"
  297.         echo "machine after the upgrade to avoid NSS-related trouble."
  298.         echo
  299.         frontend=`echo "$DEBIAN_FRONTEND" | tr '[:upper:]' '[:lower:]'`
  300.         if [ "$frontend" = noninteractive ]; then
  301.             echo "Non-interactive mode, restarting services"
  302.             answer=yes
  303.         else
  304.             echo -n "Do you wish to restart services? [Y/n] "
  305.             read answer
  306.             case $answer in
  307.             Y*|y*) answer=yes ;;
  308.             N*|n*) answer=no ;;
  309.             *) answer=yes ;;
  310.             esac
  311.         fi
  312.         echo
  313.         if [ "$answer" = yes ] && [ "$services" != "" ]; then
  314.             echo "Restarting services possibly affected by the upgrade:"
  315.             failed=""
  316.             for service in $services; do
  317.             if [ -f /usr/share/file-rc/rc ] || [ -f /usr/lib/file-rc/rc ] && [ -f /etc/runlevel.conf ]; then
  318.                 idl=$(filerc $rl $service)
  319.             else
  320.                 idl=$(ls /etc/rc${rl}.d/S??${service} 2> /dev/null | head -1)
  321.             fi
  322.             echo -n "  $service: stopping..."
  323.             $idl stop > /dev/null 2>&1 || true
  324.             sleep 2
  325.             echo -n "starting..."
  326.             if $idl start > /dev/null 2>&1; then
  327.                 echo "done."
  328.             else
  329.                 echo "FAILED! ($?)"
  330.                 failed="$service $failed"
  331.             fi
  332.             done
  333.             echo
  334.             if [ -n "$failed" ]; then
  335.             # Ruh roh, George
  336.             echo "The following services failed to start: $failed"
  337.             echo
  338.             echo "You will need to start these manually by running \`/etc/init.d/<service> start'"
  339.             echo "If the service still fails to start, you may need to file a bug on"
  340.             echo "$(package_name) or the service involved."
  341.             if [ "$DEBIAN_FRONTEND" != noninteractive ]; then
  342.                 echo
  343.                 echo -n "Press ENTER to continue: "
  344.                 read foo
  345.             fi
  346.             else
  347.             echo "Services restarted successfully."
  348.             fi
  349.             echo
  350.         fi
  351.         fi
  352.     fi # end upgrading and $preversion lt 2.3.5-1
  353.     fi # Upgrading
  354.  
  355.     # Ubuntu change.  Do not do kernel version detection at startup.
  356.     update-rc.d -f glibc.sh remove >/dev/null 2>&1
  357.  
  358. #    # DO NOT FOLLOW THIS EXAMPLE IN OTHER PACKAGES
  359. #     updatercd glibc.sh start 01 S .
  360. #     if [ -x /usr/sbin/invoke-rc.d ]; then
  361. #    invoke-rc.d glibc.sh start
  362. #     else
  363. #    /etc/init.d/glibc.sh 2>/dev/null || true
  364. #     fi
  365.  
  366.     # Generate cache file /usr/lib/gconv/gconv-modules.cache
  367.     iconvconfig || true
  368.  
  369. fi
  370.  
  371. if [ "`uname -s`" = Linux ]; then
  372. #
  373. #       Upgrade init if possible. There was a bug in all versions
  374. #       up to and including 2.75-4, which didn't affect i386 but
  375. #       did affect most other architectures.
  376. #
  377. sysvinitver="`dpkg -s sysvinit 2>/dev/null | grep ^Version: | sed -e 's/^Version: *//'`"
  378. case "`uname -m`" in
  379.         i?86)
  380.                 badsysvinitver="2.[0-6]*|2.7[0-3]*"
  381.                 ;;
  382.         *)
  383.                 badsysvinitver="2.[0-6]*|2.7[0-4]*|2.75-*"
  384.                 ;;
  385. esac
  386. # Black magic. If we are in a chroot, then /proc/1/exe will not resolve to
  387. # a file (will return EPERM). This keeps us from breaking things in
  388. # debootstrap, and the like.
  389. case "$sysvinitver" in
  390.         $badsysvinitver)
  391.                 ;;
  392.         *)
  393.         if [ -x /sbin/init -a -x /bin/readlink ]; then
  394.             if [ "$(readlink /proc/1/exe 2>/dev/null)" = "/sbin/init" ]; then
  395.                 (init u ; sleep 1)
  396.             fi
  397.         fi
  398.         ;;
  399. esac
  400. fi
  401.  
  402. # Automatically added by dh_makeshlibs
  403. if [ "$1" = "configure" ]; then
  404.     ldconfig
  405. fi
  406. # End automatically added section
  407.  
  408.  
  409. exit 0
  410.